<template>
  <div>
    <ZgEdit
      ref="dialog"
      :columns="columns"
      :formulas="formulas"
      :inputClick="inputClick"
      validUrl=""
      saveUrl="/zg-scf/role/add"
      :view="view"
      :setColumnKey="setColumnKey"
      @ok="$emit('ok')">
    </ZgEdit>
  </div>
</template>
<script>

export default {
  props: {
    companyLevel: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {
      view: {
        width: '60%',
        top: '3%',
        title: '新增'
      },
      columns: [
        { name: '角色名称', code: 'name', isShow: true, compType: '单行文本', isNeed: true, offset: 0, span: 24, defaultVal: '' },
        { name: '角色类型', code: 'type', isShow: true, compType: '字典', isNeed: true, offset: 0, span: 24, defaultVal: '', extra: { 字典类型: 'userType' } },
        { name: '认证状态', code: 'authStatus', isShow: true, compType: '单选', isNeed: true, offset: 0, span: 24, defaultVal: '1', extra: { 选项: [{ value: '0', label: '未认证' }, { value: '1', label: '已认证' }] } },
        { name: '企业等级', code: 'enLevelId', isShow: true, compType: '下拉选择', isNeed: false, offset: 0, span: 24, defaultVal: '', extra: { 下拉选项: this.companyLevel } },
        { name: '描述', code: 'intro', isShow: true, compType: '多行文本', isNeed: false, offset: 0, span: 24, defaultVal: '', extra: { 行数: 5 } }
      ],
      formulas: []
    }
  },
  methods: {
    // 根据数据变化修改 columns 中的显示值
    setColumnKey(param) {
      this.columns.forEach(item => {
        // // eslint-disable-next-line eqeqeq
        // if (param.type == 0) {
        //   // eslint-disable-next-line eqeqeq
        //   if (item.code == 'authStatus' || item.code == 'enLevelId') {
        //     item.isShow = false
        //   } else {
        //     item.isShow = true
        //   }
        // }
        // // eslint-disable-next-line eqeqeq
        // if (param.authStatus == 0) {
        //   // eslint-disable-next-line eqeqeq
        //   if (item.code == 'enLevelId') {
        //     item.isShow = false
        //   } else {
        //     item.isShow = true
        //   }
        // }
      })
    },
    open () {
      this.$refs.dialog.open()
    },
    inputClick (t) {
      alert(JSON.stringify(t))
    },

  },
  mounted () {
  },
}
</script>

<style lang="scss" scoped>
</style>
